<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn=null;
Statement st=null;
ResultSet rs=null;
String url="jdbc:mysql://localhost:3306/2012jb?useUnicode=true&characterEncoding=UTF-8";
String userName="root";
String password="123456";
	conn=DriverManager.getConnection(url,userName,password);
	//3. statement  or preparestatement
	st=conn.createStatement();
	//4.execute sql ResultSet
	rs=st.executeQuery("SELECT ID,LOGIN_NAME,PASSWORD FROM USER");
	//5. data handle
	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<a href="add.jsp">Add User</a>
	<table border="1">
		<tr>
			<td>ID</td>
			<td>LoginName</td>
			<td>Password</td>
			<td>Operate</td>
		</tr>
		<%while(rs.next()) {%>
		<tr>
			<td><%=rs.getInt("ID") %></td>
			<td><%=rs.getString("LOGIN_NAME") %></td>
			<td><%=rs.getString("PASSWORD") %></td>
			<td><a href="del.jsp?id=<%=rs.getInt("ID") %>">Del</a>
			<a href="edit.jsp?id=<%=rs.getInt("ID") %>">Edit</a></td>
		</tr>
		<%}
		 if(rs!=null)rs.close();
		 if(st!=null)st.close();
		 if(conn!=null)conn.close();
		%>
	</table>
</body>
</html>